/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AbmAnimal2.java
 *
 * Created on 19/06/2011, 23:39:11
 */
package visuales;

import entidades.Animal;
import entidades.Bateria;
import entidades.Camara;
import entidades.Categoria;
import entidades.Item;
import entidades.Jaula;
import entidades.Sexo;
import entidades.TipoEvento;
import gestores.GestorProduccion;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import oracle.sql.DATE;

/**
 *
 * @author Facundo
 */
public class AbmAnimal2 extends javax.swing.JFrame {

    private GestorProduccion gp;
    private JFrame padre;
    private Camara camara;
    private Item res_item;
    private int solapa_seleccionada;
    private String dato_ubicacion;
    private DefaultListModel res_lista;
//    public static final int FLAP_DESTETE = 0;
//    public static final int FLAP_RALGRO = 1;
//    public static final int FLAP_PELETEO = 2;

    /** Creates new form AbmAnimal2 */
    public AbmAnimal2(JFrame pantalla, int flap) {
        initComponents();
        this.padre = pantalla;
        this.solapa_seleccionada = flap;
        jTabbedPane1.setSelectedIndex(this.solapa_seleccionada);
        gp = new GestorProduccion();
        this.inicial();
    }

    private void inicial() {
        System.out.println("Solapa seleccionada: " + this.solapa_seleccionada);
        switch (this.solapa_seleccionada) {
            case TipoEvento.DESTETE:
                System.out.println("Solapa seleccionada: DESTETE");
                System.out.println("Limpiando combo de animales a destetar.");
//                cmbAnimalDestete.removeAll();
                boolean res = this.cargarComboDestete();
                if (res == true) {
                    System.out.println("Empezando a cargar los combos existentes en el form...");
                    if (this.cargarComboUbicacion() == false) {
                        String msg = "No hay ubicaciones disponibles, no se puede realizar el destete.";
                        this.mensajeError(this.btnRegistrarDestete, msg);
                    } else {
                        this.cargarComboCategoria();
                        this.setFechaDestete();
                    }
                } else {
                    String msg = "Atencion - No hay animales para destetar en el dia de la fecha.";
                    this.mensajeError(this.btnMostrarUbicacion, null);
                    this.mensajeError(this.btnRegistrarDestete, msg);
                }
                break;
            case TipoEvento.RALGRO:
                System.out.println("Solapa seleccionada: RALGRO");
                break;
            case TipoEvento.PELETEO:
                System.out.println("Limpiando combo de animales a peletear.");
                cmbAnimalesPeleteo.removeAllItems();
                System.out.println("Solapa seleccionada: PELETEO");
                res_lista = new DefaultListModel();
                boolean res_peleteo = this.cargarComboPeleteo();
                if (!res_peleteo) {
                    this.mensajeError(this.btnSeleccionarPeleteo, null);
                    this.mensajeError(this.btnAceptarPeleteo, "No existen animales a ser peleteados.");
                }
                break;
        }
    }

    private void mensajeError(JButton boton, String msg) {
        if (boton != null) {
            boton.setEnabled(false);
        }
        if (msg != null) {
            System.out.println("Error: " + msg);
            JOptionPane.showMessageDialog(null, msg, "Atencion", JOptionPane.ERROR_MESSAGE);
        }
        return;
    }

    private void setFechaDestete() {
        System.out.println("Tomando fecha de destete: ");
        DATE fecha_destete = gp.tomarFechaSistema();
        txtFechaDestete.setText(String.valueOf(fecha_destete.dateValue()));
        System.out.println("La fecha de destete tomado es: ");
//        txtFechaDestete.setText(gp.tomarFechaSistema().stringValue().substring(0, 9));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupoRadioButton = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        txtMadreDestete = new javax.swing.JTextField();
        lblMadre = new javax.swing.JLabel();
        lblPadre = new javax.swing.JLabel();
        txtPadreDestete = new javax.swing.JTextField();
        lblNombre = new javax.swing.JLabel();
        cmbAnimalDestete = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        txtFechaNacimientoDestete = new javax.swing.JFormattedTextField();
        txtFechaDestete = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btnRadioMachoDestete = new javax.swing.JRadioButton();
        btnRadioHembraDestete = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        cmbCategoriaDestete = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        txtUbicacionDestete = new javax.swing.JTextField();
        btnMostrarUbicacion = new javax.swing.JButton();
        jcb_ubicacion_destete = new javax.swing.JComboBox();
        btnRegistrarDestete = new javax.swing.JButton();
        btnImprimirTarjetaDestete = new javax.swing.JButton();
        btnCancelarDestete = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        btnBuscarAnimalRalgro = new javax.swing.JButton();
        txtAnimalRalgro = new javax.swing.JTextField();
        jPanel15 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        txtFechaNacimientoRalgro = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtFechaRalgro = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txtUbicacionRlagro = new javax.swing.JTextField();
        jPanel16 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtAComentrios = new javax.swing.JTextArea();
        btnRegistraRalgro = new javax.swing.JButton();
        btnCancelarRalgro = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        btnSeleccionarPeleteo = new javax.swing.JButton();
        cmbAnimalesPeleteo = new javax.swing.JComboBox();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        btnCancelarPeleteo = new javax.swing.JButton();
        btnAceptarPeleteo = new javax.swing.JButton();
        btnBorrarAnimalPeleteo = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("PampaChin- Animales");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos iniciales:"));

        txtMadreDestete.setEditable(false);

        lblMadre.setText("Madre :");

        lblPadre.setText("Padre :");

        txtPadreDestete.setEditable(false);

        lblNombre.setText("Seleccionar animal:");

        cmbAnimalDestete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbAnimalDesteteActionPerformed(evt);
            }
        });

        jLabel5.setText("Fecha de nacimiento:");

        txtFechaNacimientoDestete.setEditable(false);
        txtFechaNacimientoDestete.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));

        txtFechaDestete.setEditable(false);
        txtFechaDestete.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));

        jLabel6.setText("Fecha de destete:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(lblMadre)
                                .addGap(18, 18, 18)
                                .addComponent(txtMadreDestete, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(lblPadre)
                                .addGap(18, 18, 18)
                                .addComponent(txtPadreDestete))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(163, 163, 163))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(lblNombre)
                                .addGap(18, 18, 18)
                                .addComponent(cmbAnimalDestete, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(txtFechaNacimientoDestete, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtFechaDestete, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))))
                .addContainerGap(89, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblNombre)
                            .addComponent(cmbAnimalDestete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblMadre)
                            .addComponent(txtMadreDestete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblPadre)
                            .addComponent(txtPadreDestete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtFechaNacimientoDestete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtFechaDestete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Ingresar:"));

        jLabel1.setText("Sexo:");

        grupoRadioButton.add(btnRadioMachoDestete);
        btnRadioMachoDestete.setSelected(true);
        btnRadioMachoDestete.setText("Macho");

        grupoRadioButton.add(btnRadioHembraDestete);
        btnRadioHembraDestete.setText("Hembra");

        jLabel2.setText("Categoría:");

        jLabel3.setText("Ubicación:");

        btnMostrarUbicacion.setText("Mostrar datos");
        btnMostrarUbicacion.setEnabled(false);
        btnMostrarUbicacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMostrarUbicacionActionPerformed(evt);
            }
        });

        jcb_ubicacion_destete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcb_ubicacion_desteteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(btnRadioMachoDestete)
                        .addGap(18, 18, 18)
                        .addComponent(btnRadioHembraDestete))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(18, 18, 18)
                                .addComponent(jcb_ubicacion_destete, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                                .addComponent(cmbCategoriaDestete, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(64, 64, 64)
                                .addComponent(btnMostrarUbicacion))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(txtUbicacionDestete, javax.swing.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(btnRadioMachoDestete)
                            .addComponent(btnRadioHembraDestete))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(cmbCategoriaDestete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnMostrarUbicacion))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jcb_ubicacion_destete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtUbicacionDestete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnRegistrarDestete.setText("Registrar");
        btnRegistrarDestete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistrarDesteteActionPerformed(evt);
            }
        });

        btnImprimirTarjetaDestete.setText("Imprimir Tarjeta");
        btnImprimirTarjetaDestete.setEnabled(false);

        btnCancelarDestete.setText("Cancelar");
        btnCancelarDestete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarDesteteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnRegistrarDestete)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnImprimirTarjetaDestete)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCancelarDestete)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRegistrarDestete)
                    .addComponent(btnImprimirTarjetaDestete)
                    .addComponent(btnCancelarDestete))
                .addContainerGap(47, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Registrar Destete", jPanel1);

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder("Seleccionar Animal"));

        jLabel7.setText("Animal:");

        btnBuscarAnimalRalgro.setText("Buscar");
        btnBuscarAnimalRalgro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarAnimalRalgroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtAnimalRalgro, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnBuscarAnimalRalgro)
                .addContainerGap(322, Short.MAX_VALUE))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(btnBuscarAnimalRalgro)
                    .addComponent(txtAnimalRalgro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Animal"));

        jLabel8.setText("Fecha Nacimiento:");

        txtFechaNacimientoRalgro.setEditable(false);

        jLabel9.setText("Fecha Ralgro:");

        txtFechaRalgro.setEditable(false);

        jLabel10.setText("Ubicación:");

        txtUbicacionRlagro.setEditable(false);

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder("Ralgro"));

        jLabel11.setText("Agregar comentario:");

        txtAComentrios.setColumns(20);
        txtAComentrios.setRows(5);
        jScrollPane1.setViewportView(txtAComentrios);

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE)
                    .addComponent(jLabel11))
                .addContainerGap())
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnRegistraRalgro.setText("Aplicar ralgro");
        btnRegistraRalgro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistraRalgroActionPerformed(evt);
            }
        });

        btnCancelarRalgro.setText("Cancelar");
        btnCancelarRalgro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarRalgroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel16, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(btnRegistraRalgro, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCancelarRalgro))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addComponent(txtFechaNacimientoRalgro, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtFechaRalgro, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(txtUbicacionRlagro))))
                .addContainerGap())
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(txtFechaNacimientoRalgro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(txtFechaRalgro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(txtUbicacionRlagro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRegistraRalgro)
                    .addComponent(btnCancelarRalgro))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel14, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(60, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Registrar Ralgro", jPanel4);

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Animales disponibles para peletear al día de hoy:"));

        jLabel4.setText("Seleccionar animales:");

        btnSeleccionarPeleteo.setText("Seleccionar");
        btnSeleccionarPeleteo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSeleccionarPeleteoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cmbAnimalesPeleteo, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnSeleccionarPeleteo)
                .addContainerGap(140, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cmbAnimalesPeleteo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSeleccionarPeleteo))
                .addGap(25, 25, 25))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Animales peleteados en el día de hoy:"));

        jScrollPane2.setViewportView(jList1);

        btnCancelarPeleteo.setText("Cancelar");
        btnCancelarPeleteo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarPeleteoActionPerformed(evt);
            }
        });

        btnAceptarPeleteo.setText("Peletear");
        btnAceptarPeleteo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarPeleteoActionPerformed(evt);
            }
        });

        btnBorrarAnimalPeleteo.setText("Borrar seleccion");
        btnBorrarAnimalPeleteo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBorrarAnimalPeleteoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnCancelarPeleteo)
                        .addGap(28, 28, 28)
                        .addComponent(btnBorrarAnimalPeleteo, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnAceptarPeleteo, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel7Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 552, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAceptarPeleteo)
                    .addComponent(btnBorrarAnimalPeleteo)
                    .addComponent(btnCancelarPeleteo))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(32, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Registrar Peleteo", jPanel5);

        btnSalir.setText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnSalir)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 628, Short.MAX_VALUE))
                .addGap(34, 34, 34))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnSalir)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSeleccionarPeleteoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSeleccionarPeleteoActionPerformed
        this.tomarSeleccionAnimalesPeletear();
}//GEN-LAST:event_btnSeleccionarPeleteoActionPerformed

    private void cmbAnimalDesteteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbAnimalDesteteActionPerformed
        this.animalSeleccionado();
    }//GEN-LAST:event_cmbAnimalDesteteActionPerformed

    private void btnMostrarUbicacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMostrarUbicacionActionPerformed
//        this.presentarJaulasDisponibles();
        Item aux = (Item) jcb_ubicacion_destete.getSelectedItem();
        this.setItem(aux);
        txtUbicacionDestete.setText(aux.getCamara() + " - " + aux.getBateria());
    }//GEN-LAST:event_btnMostrarUbicacionActionPerformed

    private void btnRegistrarDesteteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarDesteteActionPerformed
        this.tomarConfirmacion(true);
    }//GEN-LAST:event_btnRegistrarDesteteActionPerformed

    private void btnCancelarDesteteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarDesteteActionPerformed
        this.tomarConfirmacion(false);
    }//GEN-LAST:event_btnCancelarDesteteActionPerformed

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        this.tomarConfirmacion(false);
        padre.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_btnSalirActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
////        System.out.println("sout");
//        camara = gp.getCamaraSeleccionada();
//        if (camara != null) {
////            System.out.println("sout2");
//            txtUbicacionDestete.setText(this.gp.getCamaraSeleccionada().getNombre() + " - " + this.gp.getJaulaSeleccionada().getNombre());
//        }
    }//GEN-LAST:event_formWindowActivated

//    private Jaula getJaulaPorCamara() {
//
//        Iterator iter_camara = this.gp.buscarUbicacionDisponible().iterator();
//        while (iter_camara.hasNext()) {
//            Camara cam = (Camara) iter_camara.next();
//            this.camara = cam;
//            ArrayList res_bateria = cam.getBateria();
//            Iterator iter_bateria = res_bateria.iterator();
//            while (iter_bateria.hasNext()) {
//                Bateria bat = (Bateria) iter_bateria.next();
//                ArrayList res_jaula = bat.getJaula();
//                Iterator iter_jaula = res_jaula.iterator();
//                while (iter_jaula.hasNext()) {
//                    Jaula jaula = (Jaula) iter_jaula.next();
//                }
//            }
//        }
//
//
//        return null;
//    }
    private void btnRegistraRalgroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistraRalgroActionPerformed
        this.tomarConfirmacion(true);
    }//GEN-LAST:event_btnRegistraRalgroActionPerformed

    private void btnCancelarRalgroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarRalgroActionPerformed
        this.tomarConfirmacion(false);
    }//GEN-LAST:event_btnCancelarRalgroActionPerformed

    private void btnAceptarPeleteoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarPeleteoActionPerformed
        this.tomarConfirmacion(true);
    }//GEN-LAST:event_btnAceptarPeleteoActionPerformed

    private void btnCancelarPeleteoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarPeleteoActionPerformed
        this.tomarConfirmacion(false);
    }//GEN-LAST:event_btnCancelarPeleteoActionPerformed

    private void btnBuscarAnimalRalgroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarAnimalRalgroActionPerformed
        this.buscarAnimal(txtAnimalRalgro.getText().toUpperCase());
        System.out.println("nombre de animal a ralgrear: " + txtAnimalRalgro.getText().toUpperCase());
}//GEN-LAST:event_btnBuscarAnimalRalgroActionPerformed

    private void btnBorrarAnimalPeleteoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBorrarAnimalPeleteoActionPerformed
        this.res_lista.remove(jList1.getSelectedIndex());
    }//GEN-LAST:event_btnBorrarAnimalPeleteoActionPerformed

    private void jcb_ubicacion_desteteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcb_ubicacion_desteteActionPerformed
//        System.out.println("linea 802");
        Item aux = (Item) jcb_ubicacion_destete.getSelectedItem();
        this.setItem(aux);
        txtUbicacionDestete.setText(aux.getDato());//aux.getCamara() + " - " + aux.getBateria());
    }//GEN-LAST:event_jcb_ubicacion_desteteActionPerformed
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new AbmAnimal2().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptarPeleteo;
    private javax.swing.JButton btnBorrarAnimalPeleteo;
    private javax.swing.JButton btnBuscarAnimalRalgro;
    private javax.swing.JButton btnCancelarDestete;
    private javax.swing.JButton btnCancelarPeleteo;
    private javax.swing.JButton btnCancelarRalgro;
    private javax.swing.JButton btnImprimirTarjetaDestete;
    private javax.swing.JButton btnMostrarUbicacion;
    private javax.swing.JRadioButton btnRadioHembraDestete;
    private javax.swing.JRadioButton btnRadioMachoDestete;
    private javax.swing.JButton btnRegistraRalgro;
    private javax.swing.JButton btnRegistrarDestete;
    private javax.swing.JButton btnSalir;
    private javax.swing.JButton btnSeleccionarPeleteo;
    private javax.swing.JComboBox cmbAnimalDestete;
    private javax.swing.JComboBox cmbAnimalesPeleteo;
    private javax.swing.JComboBox cmbCategoriaDestete;
    private javax.swing.ButtonGroup grupoRadioButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JComboBox jcb_ubicacion_destete;
    private javax.swing.JLabel lblMadre;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblPadre;
    private javax.swing.JTextArea txtAComentrios;
    private javax.swing.JTextField txtAnimalRalgro;
    private javax.swing.JFormattedTextField txtFechaDestete;
    private javax.swing.JFormattedTextField txtFechaNacimientoDestete;
    private javax.swing.JTextField txtFechaNacimientoRalgro;
    private javax.swing.JTextField txtFechaRalgro;
    private javax.swing.JTextField txtMadreDestete;
    private javax.swing.JTextField txtPadreDestete;
    private javax.swing.JTextField txtUbicacionDestete;
    private javax.swing.JTextField txtUbicacionRlagro;
    // End of variables declaration//GEN-END:variables

    private boolean cargarComboDestete() {
        System.out.println("En cargarComboDestete:");
        ArrayList<Animal> para_destete = gp.buscarAnimalesParaDestetar();
        if (para_destete == null) {
            System.out.println("No se pudo cargar el cambo...");
            return false;
        } else {
            Iterator iter = para_destete.iterator();
            Animal aux = null;
            System.out.println("Cargando el combo de animales a destetar...");
            int nro_ani = 1;
            while (iter.hasNext()) {
                aux = (Animal) iter.next();
                System.out.println("Nro de animal a destetar: " + nro_ani + " - Nombre del animal a destetar: " + aux.getNombre());
                cmbAnimalDestete.addItem(aux);
                nro_ani++;
            }
            System.out.println("Combo de animales a destetar cargado con exito :)");
            return true;
        }
    }

    private boolean cargarComboCategoria() {
        System.out.println("Buscando categorias existentes...");
        ArrayList<Categoria> paraCategoria = gp.allCategorias();
        if (paraCategoria != null || paraCategoria.isEmpty() == true) {
            System.out.println("Cargando el combo de categorias de pieles...");
            Iterator iter = paraCategoria.iterator();
            Categoria aux = null;
            while (iter.hasNext()) {
                aux = (Categoria) iter.next();
                cmbCategoriaDestete.addItem(aux);
            }
            System.out.println("Combo cargado :)");
            return true;
        } else {
            System.out.println("El combo de categorias no ha sido cargado :(");
            return false;
        }
    }

    private void presentarAnimales(Animal animalSeleccionado) {
        txtMadreDestete.setText(animalSeleccionado.getMadre().getNombre());
        txtPadreDestete.setText(animalSeleccionado.getPadre().getNombre());
        txtFechaNacimientoDestete.setText(String.valueOf(animalSeleccionado.getFecha_nacimiento().dateValue()));
    }

    private void animalSeleccionado() {
        Animal res = (Animal) cmbAnimalDestete.getSelectedItem();
        this.presentarAnimales(res);
        gp.setAnimalSeleccionado(res);
    }

    private void sexoSeleccionado() {
        Sexo sexo = new Sexo();
        if (btnRadioHembraDestete.isSelected()) {
            sexo.setDescripcion("Hembra");
            sexo.setNombre('H');
        } else {
            sexo.setDescripcion("Macho");
            sexo.setNombre('M');
        }
        gp.sexoSeleccionado(sexo);
    }

    private void categoriaSeleccionado() {
        gp.categoriaSeleccionado((Categoria) cmbCategoriaDestete.getSelectedItem());
    }

    private void jaulaSeleccionado() {
//        gp.jaulaSeleccionado(this.camara);
        Camara res_cam = this.res_item.getCamara();
        System.out.println("res_cam: " + res_cam.getNombre());
        gp.jaulaSeleccionado(res_cam);
    }

    private void tomarConfirmacion(boolean acepto) {
        String res;
        System.out.println("Confirmando acciones: " + acepto);
        if (acepto) {
            switch (this.solapa_seleccionada) {
                case TipoEvento.DESTETE:
                    System.out.println("Tomando sexo, categoria y ubicacion del animal...");
                    this.sexoSeleccionado();
                    this.categoriaSeleccionado();
                    this.jaulaSeleccionado();
                    break;
                case TipoEvento.RALGRO:
                    System.out.println("Tomando observacion de la aplicacion del ralgro...");
                    this.tomarObservacionRalgro();
                    break;
                case TipoEvento.PELETEO:
                    System.out.println("Tomando la lista de animales que van a ser peleteados...");
                    this.tomarAnimalesPeletear();
                    break;
            }
            res = gp.confirmacionAceptada(acepto, this.solapa_seleccionada);
            System.out.println("Se pudieron confirmar las acciones solicitadas?: " + res);
            if (res.compareToIgnoreCase("OK") == 0) {
//                this.inicial();
                JOptionPane.showMessageDialog(this, res);
                this.dispose();
                this.padre.setVisible(true);
                System.out.println("Segundo vuelta");
            }
        } else {
            res = gp.confirmacionAceptada(acepto, -1);
            System.out.println("Se cancela las acciones que se estaban realizando: " + res);
            this.dispose();
            this.padre.setVisible(true);
        }
    }

    private void tomarObservacionRalgro() {
        gp.setObservacionVarias(txtAComentrios.getText());
    }

    private void buscarAnimal(String nombreAnimal) {
        Animal res = gp.getAnimalRalgro(nombreAnimal);
        if (res != null) {
            System.out.println("Animal encontrado con exito...\nMostrando datos del animal encontrado...");
            gp.setAnimalSeleccionado(res);
            txtFechaNacimientoRalgro.setText(String.valueOf(res.getFecha_nacimiento().dateValue()));
            txtFechaRalgro.setText(String.valueOf(gp.tomarFechaSistema().dateValue()));
            txtUbicacionRlagro.setText(res.getUbicacion().getTipo_camara().getNombre());
        } else {
            this.mensajeError(this.btnRegistraRalgro, "El animal ingresado es incorrecto, aun no a sido destetado o ya sido peleteado el animal que busca...");
//            System.out.println("");
//            JOptionPane.showMessageDialog(this, "Animal no encontrado", "Error al ingresar el nombre del animal", JOptionPane.INFORMATION_MESSAGE);
        }
    }

    private boolean cargarComboUbicacion() {
        //obtengo el objeto camara y muestro el en una caja de texto, la bateria y la jaula.
        System.out.println("Empezando a cargar el combo ");
        String dato_jaula = "";
        Item item = null;
        Jaula jaula = null;
        Bateria bateria = null;
        Camara res_camara = null;
        ArrayList camaras_disponible = gp.buscarUbicacionDisponible();
        if (camaras_disponible != null || camaras_disponible.isEmpty() == false) {
            Iterator iter_camara = camaras_disponible.iterator();
            Iterator iter_bateria, iter_jaula;
            while (iter_camara.hasNext()) {
                res_camara = (Camara) iter_camara.next();
                iter_bateria = res_camara.getBateria().iterator();
                while (iter_bateria.hasNext()) {
                    bateria = (Bateria) iter_bateria.next();
                    iter_jaula = bateria.getJaula().iterator();
                    while (iter_jaula.hasNext()) {
                        jaula = (Jaula) iter_jaula.next();
                        item = new Item(bateria, res_camara, jaula + " - " + bateria + " - " + res_camara + " - " + res_camara.getTipo_camara().getNombre(), jaula);
                        jcb_ubicacion_destete.addItem(item);
                    }
                }
//                jaula = (Jaula) iter.next();
//                jcb_ubicacion_destete.addItem(jaula);
            }
            return true;
        } else {
            return false;
        }
//        if (camaras_disponible == null || camaras_disponible.isEmpty() == true) {
//            System.out.println("No hay ubicaciones disponibles...\nNo se puede cargar el combo....");
//            return false;
//        } else {
//            System.out.println("Existen ubicaciones disponibles...");
//            Iterator iter_cam_disponibles = camaras_disponible.iterator();
//            System.out.println("Exite al menos una camara...");
//            Bateria bat_aux = null;
//            Camara cam_aux = null;
//            Jaula jau_aux = null;
//            while (iter_cam_disponibles.hasNext()) {
//                cam_aux = (Camara) iter_cam_disponibles.next();
////            System.out.println("Nombre de la camara: "+cam_aux.getNombre());
//                dato_jaula = "Camara: " + cam_aux.getNombre() + " - ";
//                //vamos a ver que tienen las camaras:
//                ArrayList res_bateria = cam_aux.getBateria();
//                Iterator iter_res_bateria = res_bateria.iterator();
//                while (iter_res_bateria.hasNext()) {
//                    bat_aux = (Bateria) iter_res_bateria.next();
////                System.out.println("Nombre de la bateria: "+bat_aux.getNombre());
//                    dato_jaula += "Bateria: " + bat_aux.getNombre();
//                    ArrayList res_jaula = bat_aux.getJaula();
//                    Iterator iter_res_jaula = res_jaula.iterator();
//                    while (iter_res_jaula.hasNext()) {
//                        jau_aux = (Jaula) iter_res_jaula.next();
////                    System.out.println("Nombre de la jaula: "+jau_aux.getNombre());//+", estado : "+jau_aux.getEstado().getNombre());
////                    dato_jaula+="Nombre de la jaula: "+jau_aux.getNombre();
//                        this.dato_ubicacion = dato_jaula;
//                        System.out.println(dato_jaula);
//                        item = new Item(bat_aux, cam_aux, dato_jaula, jau_aux);
//                        System.out.println("Datos de la ubicacion disponible: " + item.mostrarItem());
////                    jcb_ubicacion_destete.addItem(jau_aux);
//                        jcb_ubicacion_destete.addItem(item);
//                    }
//                }
//            }
//            return true;
//        }
    }

    private void setItem(Item item) {
        res_item = item;
    }

    private Item getItem() {
        return this.res_item;
    }

    private void setCamara(Camara camara) {
        this.camara = camara;
    }

    private boolean cargarComboPeleteo() {
        System.out.println("Cargando el combo de animales que van a ser peleteados...");
        boolean res = false;
        Animal res_animal = null;
        ArrayList animalesPeletear = gp.buscarAnimalesParaPeletear();
        if (animalesPeletear != null && animalesPeletear.isEmpty() == false) {
            Iterator iter_animalesPeletear = animalesPeletear.iterator();
            while (iter_animalesPeletear.hasNext()) {
                res_animal = (Animal) iter_animalesPeletear.next();
                cmbAnimalesPeleteo.addItem(res_animal);
            }
            res = true;
        }
        return res;
    }

    private void tomarSeleccionAnimalesPeletear() {
        System.out.println("Seleccionando los animales que han sido peleteados...");
        Animal res_animal = (Animal) cmbAnimalesPeleteo.getSelectedItem();
        if (res_lista.contains(res_animal)) {
            this.mensajeError(null, "El animal " + res_animal.getNombre() + " ya sido seleccionado...");
        } else {
            res_lista.addElement(res_animal);
            jList1.setModel(res_lista);
        }
    }

    private void tomarAnimalesPeletear() {
        gp.setListaPeletear(res_lista);
//        System.out.println("No se que se hace aca...");
    }
}
